﻿using Sprout.Schedule.Dtos;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Sprout.Schedule.Interfaces
{
    public interface IJobManagerService
    {
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        Task Initialize();

        /// <summary>
        /// 新增计划任务
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        Task StartJob(TaskInfo item);

        /// <summary>
        /// 暂停任务
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        Task PauseJob(long jobId);

        /// <summary>
        /// 修改计划任务
        /// </summary>
        /// <param name="jobId"></param>
        /// <param name="cronExpression"></param>
        /// <returns></returns>
        Task UpdateJob(long jobId, string cronExpression);

        /// <summary>
        /// 移除一个计划任务
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        Task RemoveJob(long jobId);

        /// <summary>
        /// 恢复任务
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        Task ResumeJob(long jobId);

        /// <summary>
        /// 中止任务
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        Task Interrupt(long jobId);

        /// <summary>
        /// 运行所有任务。
        /// </summary>
        /// <returns></returns>
        Task StartJobs();

        /// <summary>
        /// 关闭所有任务。
        /// </summary>
        /// <param name="waitForJobsToComplete">是否等待任务完成</param>
        /// <returns></returns>
        Task StopJobs(bool waitForJobsToComplete);

        /// <summary>
        /// 暂停所有任务。
        /// </summary>
        /// <returns></returns>
        Task PauseAllJobs();

        /// <summary>
        /// 恢复所有任务。
        /// </summary>
        /// <returns></returns>
        Task ResumeAllJobs();

        /// <summary>
        /// 立即执行任务。
        /// </summary>
        /// <param name="jobId">任务ID</param>
        /// <returns></returns>
        Task TriggerJob(long jobId);
    }
}
